﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Business;

namespace TimKiemDiaDiem
{
    public partial class TimKiemNangCaoCtrl : LoaiTimKiemCtrl
    {
        public TimKiemNangCaoCtrl()
        {
            InitializeComponent();

            List<DuongDTO> DanhSachDuong = XL_Duong.layDanhSachCacConDuong();
            cbbTenDuong.Items.Add("Tất cả con đường");

            for (int index = 0; index < DanhSachDuong.Count; ++index)
            {
                cbbTenDuong.Items.Add(DanhSachDuong[index].TenDuong);
            }

            //cbbTenDuong.DataSource = XL_Duong.layDanhSachCacConDuong();
            
            cbbTenDuong.Text = (String)cbbTenDuong.Items[0];
        }

        public override List<Business.DiaDiemDTO> TraCuuDiaDiem()
        {
            String TenDichVu = "";
            if ("TatCa" == m_TenDichVu)
            {
                TenDichVu = cbbDichVu.Text;
            }
            else
            {
                TenDichVu = m_TenDichVu;
            }

            String TenDuong = cbbTenDuong.Text;
            if ("Tất cả con đường" == TenDuong)
            {
                return XL_DiaDiem.tracuuDiaDiem(TenDichVu , txtTuKhoa.Text);
            }
            return XL_DiaDiem.tracuuDiaDiem(TenDichVu , TenDuong + txtTuKhoa.Text);
        }

        private void TimKiemNangCaoCtrl_Load(object sender, EventArgs e)
        {
            if ("TatCa" != m_TenDichVu)
            {
                lblDichVu.Visible = false;
                cbbDichVu.Visible = false;
                return;
            }
            cbbDichVu.DataSource = XL_DichVu.layDanhSachDichVu();
        }
    }
}
